<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>多选下拉列</title>
    <script>
        function move(fromId,toId){
            let fromChild = document.getElementById(fromId);
            let toChild = document.getElementById(toId);

            for(let i = 0; i < fromChild.length; i++){
                if(fromChild.options[i].selected){
                    fromChild.options[i].style.color = "#dddddd";
                    toChild.options[i].style.color = "#000000";
                    // 取消选中效果
                    fromChild.options[i].selected = false;
                }
            }
        }
        function moveAll(fromId,toId){
            let fromChild = document.getElementById(fromId);
            let toChild = document.getElementById(toId);

            for(let i = 0; i < fromChild.length; i++){
                fromChild.options[i].style.color = "#dddddd";
                toChild.options[i].style.color = "#000000";
                // 取消选中效果
                fromChild.options[i].selected = false;
            }
        }
    </script>
</head>
<body>
<table>
    <tr>
        <td>
            <select id="s1" multiple="multiple" style="width: 100px;height: 150px;">
                <option style="color: #000000;">admin</option>
                <option style="color: #000000;">alice</option>
                <option style="color: #000000;">jack</option>
                <option style="color: #000000;">tom</option>
            </select>
        </td>
        <td>
            <input type="button" value="&nbsp;-->" onclick="move('s1','s2')"/><br/>
            <input type="button" value="->>" onclick="moveAll('s1','s2')"/><br/>
            <input type="button" value="<--&nbsp;" onclick="move('s2','s1')"/><br/>
            <input type="button" value="<<-" onclick="moveAll('s2','s1')"/><br/>
        </td>
        <td>
            <select id="s2" multiple="multiple" style="width: 100px;height: 150px;">
                <option style="color: #dddddd;">admin</option>
                <option style="color: #dddddd;">alice</option>
                <option style="color: #dddddd;">jack</option>
                <option style="color: #dddddd;">tom</option>
            </select>
        </td>
    </tr>
</table>
</body>
</html>